using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class Rope : MonoBehaviour {
	
	public float m_ropeLen;
	public float m_ropeWid;

	
	void Start(){
		transform.localScale = new Vector3(m_ropeWid,m_ropeLen,1);
		GetComponentInChildren<Renderer>().sharedMaterial.mainTextureScale = new Vector2(1,transform.lossyScale.y/transform.lossyScale.x);
	}
	
	public void ReCalcMat(){
		if(m_ropeLen<1)m_ropeLen = 1;
		transform.localScale = new Vector3(m_ropeWid,m_ropeLen,1);
		GetComponentInChildren<Renderer>().sharedMaterial.mainTextureScale = new Vector2(1,transform.lossyScale.y/transform.lossyScale.x);
	}
#if UNITY_EDITOR
	void Update(){
		
		ReCalcMat();
		
		
	}
#endif
	
}
